package com.blog.service.frontpage;

import java.util.List;

import com.blog.dao.conn.ParamSet;
import com.blog.dao.frontpage.ArticleDao;
import com.blog.entity.ArticleConstraintEntity;
import com.blog.entity.BolgerArticleEntity;
import com.blog.utils.Util;
/**
 * 前台文章显示页面
 * @author Administrator
 *
 */
public class ArticleService {

	ArticleDao dao=new ArticleDao();
	/**
	 * 查询所有类别（根据时间 顺序排名）
	 */
	public List<ArticleConstraintEntity> getAllArticleInfo(){
		List<ArticleConstraintEntity> ist=dao.getAllArticleInfo();
		String temp="";
		for(ArticleConstraintEntity e:ist) {
			temp=Util.removeTag(e.getArticle_content());
			if(temp.length()>200) {
				e.setArticle_content(temp.substring(0, 200));
			}
		}
		return ist;
	}
	
	
	/**
	 * 查询首页热门推荐
	 */
	public List<ArticleConstraintEntity> getHotRecommend(){
		return dao.getHotRecommend();
	}
	
	/**
	 * 根据分类查询文章所有详情
	 */
	public List<ArticleConstraintEntity> getArticleByTypes(String typenames){
		List<ArticleConstraintEntity> ist=dao.getArticleByTypes(typenames);
		String temp="";
		for(ArticleConstraintEntity e:ist) {
			temp=Util.removeTag(e.getArticle_content());
			if(temp.length()>200) {
				e.setArticle_content(temp.substring(0, 200));
			}
		}
		return ist;
	}
	
	/**
	 * 根据文章标题查询文章详情
	 */
	public ArticleConstraintEntity getArticleByTitle(String title){
		return dao.getArticleByTitle(title);
	}
	
	/**
	 *根据文章id修改浏览量
	 */
	public int updateReadNumber(int articleid) {
		return dao.updateReadNumber(articleid);
	}
	
	
}

